<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png" />
    <!-- <HelloWorld msg="Welcome to Your Vue.js App"/> -->
    <h1>点击翻书</h1>
    <div id="flipbook">
      <div
        v-for="item in imgUrl"
        :key="item.index"
        :style="`
          background:url(${item.imgurl}) no-repeat 100% 100%
          
          `"
      ></div>
    </div>
  </div>
</template>

<script>
// import HelloWorld from './components/HelloWorld.vue'
import $ from "jquery";
// 在index里引用
import turn from "./utils/turn.js";
export default {
  name: "App",
  components: {
    // HelloWorld
  },
  data() {
    return {
      imgUrl: [
        {
          index: 0,
          imgurl: require("./assets/img/1.jpg"),
        },
        {
          index: 1,
          imgurl: require("./assets/img/2.jpg"),
        },
        {
          index: 2,
          imgurl: require("./assets/img/3.jpg"),
        },
        {
          index: 3,
          imgurl: require("./assets/img/4.jpg"),
        },
        {
          index: 4,
          imgurl: require("./assets/img/5.jpg"),
        },
        {
          index: 5,
          imgurl: require("./assets/img/6.jpg"),
        },
        {
          index: 6,
          imgurl: require("./assets/img/7.jpg"),
        },
        {
          index: 7,
          imgurl: require("./assets/img/8.jpg"),
        },
        {
          index: 8,
          imgurl: require("./assets/img/9.jpg"),
        },
        {
          index: 9,
          imgurl: require("./assets/img/10.jpg"),
        },
        {
          index: 10,
          imgurl: require("./assets/img/11.jpg"),
        },
        {
          index: 11,
          imgurl: require("./assets/img/12.jpg"),
        },
      ],
    };
  },
  mounted() {
    this.onTurn();
  },
  methods: {
    onTurn() {
      this.$nextTick(() => {
        $("#flipbook").turn({
          autoCenter: true,
          height: 646,
          width: 996,
        });

        // $("#flipbook").turn({
        //   //启用硬件加速,移动端有效
        //   acceleration: false,
        //   //显示：single=单页，double=双页，默认双页
        //   display: "double",
        //   // 翻页撒开鼠标，页面的延迟
        //   duration: 800,
        //   // 默认显示第几页
        //   page: 1,
        //   // 折叠处的光泽渐变，主要体现翻页的立体感、真实感
        //   gradients: true,
        //   // 中心翻取决于有多少页面可见 true or false
        //   autoCenter: true,
        //   // 设置可翻页的页角(都试过了，乱写 4个角都能出发卷起)， bl,br   tl,tr   bl,tr
        //   turnCorners: "bl,br",
        //   //页面高度
        //   height: 646,
        //   //翻书范围宽度，总宽度
        //   width:996,
        //   when: {
        //     //监听事件
        //     turning: function (e, page, view) {
        //       console.log("翻页前触发");
        //       console.log(e, page, view);
        //       // 翻页前触发
        //       console.log(page);
        //     },
        //     turned: function (e, page) {
        //       console.log("翻页后触发");
        //       console.log(e, page);
        //       // 翻页后触发
        //       console.log(page);
        //     },
        //   },
        // });

      });
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
#flipbook {
  margin-left: 30%;
}
</style>
